<template>
	<view>
		<view class="list">
			<view class="li" v-for="(item,index) in articleArr" :key="item.id" @click="toDetail(item.imgSrc)">
				<view style="width: 100vw;">{{my_comment}}</view>
				<view class="flex solid-bottom padding align-start">
					<view class="img">
						<image :src="item.imgSrc" mode="widthFix"></image>
					</view>
					<view class="detail">
						<view class="name">名字：</view>
						<view class="adress">地址：</view>
						<view class="grade">评分：</view>
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "list",
		data() {
			return {
				my_comment: "my_comment",
				articleArr: [],
			};
		},
		methods: {
			toDetail(item) {
				uni.navigateTo({
					url: '/pages/rank_detail/index',

					success: function(res) {
						// 通过eventChannel向被打开页面传送数据
						res.eventChannel.emit('url', {
							data: item
						})
					}
				})
			}
		},
		created() {
			uniCloud.callFunction({
				name: "getNews",
				data: {
					name: "news"
				}
			}).then(res => {
				let {
					articleArr
				} = res.result.data[0];
				this.articleArr = articleArr;
				//console.log(this.articleArr);
			})
		}
	}
</script>

<style lang="scss">
	.list {
		.li:nth-child(1) {
			.rank_grade {
				background-color: #FFB400;
			}
		}

		.li:nth-child(2) {
			.rank_grade {
				background-color: #FFB400;
			}
		}

		.li:nth-child(3) {
			.rank_grade {
				background-color: #FFB400;
			}
		}

		.li {
			height: 250rpx;
			margin-top: 10rpx;
			position: relative;
			margin-left: 10%;
			margin-right: 10%;
			border-radius: 20rpx;
			overflow: hidden;
			box-shadow: 2px 2px 20rpx #ccc;
			padding: 10rpx;
			border: 1px solid #ccc;

			.img {
				width: 40%;
				overflow: hidden;

				image {
					margin-top: 0rpx;
					margin-left: 10rpx;
					width: 100%;
					filter: brightness(0.8);
				}
			}

			.rank_grade {
				position: absolute;
				top: 0rpx;
				right: 10rpx;
				background-color: #ccc;
				height: 100rpx;
				width: 80rpx;
			}



			.rank {
				color: #fff;
				font-size: 30rpx;
				position: absolute;
				right: 40rpx;
				top: 10rpx;

				.top {
					position: absolute;
					left: -40rpx;
					top: -10rpx;
				}

				.ranks {
					position: absolute;
					top: 20rpx;
					left: -24rpx;
				}

				.triangle {
					position: absolute;
					top: 70rpx;
					left: -50rpx;
					width: 0;
					height: 0;
					border-left: 40rpx solid transparent;
					border-right: 40rpx solid transparent;
					border-bottom: 10px solid white;
				}
			}

			.detail {
				position: absolute;
				left: 40%;
				top: 10rpx;

				.name {
					margin-top: 10rpx;
					margin-left: 20rpx;
				}

				.adress {
					margin-top: 10rpx;
					margin-left: 20rpx;
				}

				.grade {
					margin-top: 10rpx;
					margin-left: 20rpx;
				}
			}

			.reason {
				margin-left: 10rpx;
				font-weight: bold;
			}
		}
	}
</style>
